using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using Zwms.Data.BusinessObjects;
using Zwms.Data.Base;
using Zwms.Data.CommonObject;
using NHibernate.Criterion;
using System.Reflection;

namespace Zwms.Data.ManagerObjects
{
    public partial interface IBilInBillDetailManager : IManagerBase<Zwms.Data.BusinessObjects.BilInBillDetail, string>
    {
        // Get Methods
        BilInBillDetail GetById(System.String iBCode, System.String goodsCode);
    }

    partial class BilInBillDetailManager : ManagerBase<Zwms.Data.BusinessObjects.BilInBillDetail, string>, IBilInBillDetailManager
    {
        #region Constructors

        public BilInBillDetailManager()
            : base()
        {
        }
        public BilInBillDetailManager(INHibernateSession session)
            : base(session)
        {
        }

        #endregion

        #region Get Methods

        public override BilInBillDetail GetById(string id)
        {
            string[] keys = id.Split('^');

            if (keys.Length != 2)
                throw new Exception("Invalid Id for BilInBillDetailManager.GetById");

            return GetById(keys[0], keys[1]);
        }
        public BilInBillDetail GetById(System.String iBCode,System.String goodsCode)
        {
            ICriteria criteria = Session.GetISession().CreateCriteria(typeof(BilInBillDetail));

            criteria.Add(NHibernate.Criterion.Expression.Eq("IBCode", iBCode));
            criteria.Add(NHibernate.Criterion.Expression.Eq("GoodsCode", goodsCode));

            BilInBillDetail result = (BilInBillDetail)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
        }

      
        #endregion
    }
}